package com.suray.system.run.seer.mysql;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.suray.system.run.seer.type.SeerAgvProcess;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.Objects;

@Data
@Accessors(chain = true)
@TableName("wcs_seer_task")
public class SeerTaskDB {

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 任务 id
     */
    private String taskId;

    /**
     * 任务起点
     */
    private String startPoint;

    /**
     * 任务终点
     */
    private String endPoint;

    /**
     * 起点外面
     */
    private String startOutPoint;

    /**
     * 终点外面
     */
    private String endOutPoint;

    /**
     * 任务进度
     */
    private SeerAgvProcess process;

    /**
     * 托盘编号
     */
    private String barcode;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 完成时间
     */
    private Date endTime;

    /**
     * 起点动作
     */
    private String startOperation;

    /**
     * 终点动作
     */
    private String endOperation;

    public SeerTaskDB(String taskId, String startPoint, String startOutPoint,
                      String endPoint, String endOutPoint, String barcode,
                      String startOperation, String endOperation) {
        this.taskId = taskId;
        this.startPoint = startPoint;
        this.endPoint = endPoint;
        this.startOutPoint = startOutPoint;
        this.endOutPoint = endOutPoint;
        this.barcode = barcode;
        this.process = SeerAgvProcess.INIT;
        this.startOperation = startOperation;
        this.endOperation = endOperation;

        createTime = new Date(System.currentTimeMillis());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SeerTaskDB that = (SeerTaskDB) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(taskId, that.taskId);
    }
}
